#ifndef _DICOM_GATEWAY_H_
#define _DICOM_GATEWAY_H_

#include "dicom/storage/local_cache.h"
#include "dicom/session.h"
#include "dicom/sync_manager.h"
#include "dicom/dmv_db.h"
#include "dicom/web_server.h"
#include "dicom/dicom_conf.h"
#include "dicom/upload/hash_cache.h"
#include "dicom/upload/resume_info.h"
#include "dicom/put_handler.h"

namespace dicom {

class Gateway {
 public:
  Gateway();
  ~Gateway();

  bool LoadConfAndInit(const std::string& conf_file, bool daemon);

  void Start();

  // You should never delete following pointers
  const DicomConf* conf() const {
    return conf_;
  };
  ResumeInfoDb* resume_info_db() { return resume_info_db_; }
  LRUFileCache* cache() { return cache_; }
  SessionManager* session_mgr() { return session_mgr_; }
  SyncManager* sync_mgr() { return sync_mgr_; }
  DmvDBManager* dmv_mgr() { return dmv_mgr_; }
  WebServer* web_srv() { return web_svr_; }
  HashCache* hcache() { return hcache_; }
  PutSinkPool* put_sink_pool() { return put_sink_pool_; }

 private:
  DicomConf* conf_;
  ResumeInfoDb* resume_info_db_;
  LRUFileCache* cache_;
  PutSinkPool* put_sink_pool_;
  SessionManager* session_mgr_;
  SyncManager* sync_mgr_;
  DmvDBManager* dmv_mgr_;
  WebServer* web_svr_;
  HashCache* hcache_;
};

extern void SetGateway(Gateway* gw);
extern Gateway* GetGateway();
};

#endif  // _DICOM_GATEWAY_H_
